/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.txt.access.capability.libraries.rabbitmq.tester;

import it.txt.access.capability.libraries.rabbitmq.settings.AbstractApplicationSettings;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author seccia
 */
public class SettingLoader {

    protected static final Logger LOGGER = Logger.getLogger(SettingLoader.class.getName());

    public static AbstractApplicationSettings loadGuestSettings() throws IOException {

        InputStream inputStream = new FileInputStream("./src/main/resources/data/guestconnection.properties");
        Properties PROPS = new Properties();
        PROPS.load(inputStream);

        AbstractApplicationSettings settings = new AbstractApplicationSettings();

        String GUEST_BROKER_PORT = PROPS.getProperty("GUEST_BROKER_PORT");
        int brokerPort = new Integer(GUEST_BROKER_PORT);
        settings.setGuestBrokerPort(brokerPort);
        LOGGER.log(Level.INFO, "GUEST_BROKER_PORT: {0}", settings.getGuestBrokerPort());

        String GUEST_BROKER_HOST = PROPS.getProperty("GUEST_BROKER_HOST");
        settings.setGuestBrokerHost(GUEST_BROKER_HOST);
        LOGGER.log(Level.INFO, "GUEST_BROKER_HOST: {0}", settings.getGuestBrokerHost());

        String GUEST_BROKER_VHOST = PROPS.getProperty("GUEST_BROKER_VHOST");
        settings.setGuestBrokerVHost(GUEST_BROKER_VHOST);
        LOGGER.log(Level.INFO, "GUEST_BROKER_VHOST: {0}", settings.getGuestBrokerVHost());

        String GUEST_BROKER_USER_NAME = PROPS.getProperty("GUEST_BROKER_USER_NAME");
        settings.setGuestBrokerUserName(GUEST_BROKER_USER_NAME);
        LOGGER.log(Level.INFO, "GUEST_BROKER_USER_NAME: {0}", settings.getGuestBrokerUserName());

        String GUEST_BROKER_USER_PWD = PROPS.getProperty("GUEST_BROKER_USER_PWD");
        settings.setGuestBrokerUserPsw(GUEST_BROKER_USER_PWD);
        LOGGER.log(Level.INFO, "GUEST_BROKER_USER_NAME: {0}", settings.getGuestBrokerUserPsw());

        String ENS_AUTH_SRV_MBX = PROPS.getProperty("ENS_AUTH_SRV_MBX");
        settings.setEnsAuthServiceMBX(ENS_AUTH_SRV_MBX);
        LOGGER.log(Level.INFO, "ENS_AUTH_SRV_MBX: {0}", settings.getEnsAuthServiceMBX());

        return settings;
    }
}
